//
// Structures
//

#ifndef STRUCTURES_H
#define STRUCTURES_H

// Dimensions of input image
#define IMAGE_WIDTH (240)
#define IMAGE_HEIGHT (320)

// Number of rows per slot
#define SLOT_LENGTH (5)

// Number of slots per queue
#define QUEUE_LENGTH (4)

// Number of queues
#define TILE_NUM (2)

// Represents a single pixel
typedef struct {
	unsigned char R;
	unsigned char G;
	unsigned char B;
} Pixel;

// Represents a row of pixels
typedef struct {
	Pixel pixels[IMAGE_WIDTH];
} Row;

// Represents a number of rows that make up an image
typedef struct {
	Row rows[IMAGE_HEIGHT];
} Image;

// Represents data needed to execute a task,
// this is a number of rows from the source image.
// (memory block is aligned at 4kb intervals)
typedef struct {
	Row rows[SLOT_LENGTH];
} Slot;

// A task queue for a single tile, 
// this contains multiple slots which can be filled with task data.
typedef struct {
	Slot slots[QUEUE_LENGTH];
} TileQueue;

// Represents the entire task queue,
// this is split into seperate queues for each tile.
typedef struct {
	TileQueue tiles[TILE_NUM];
} Queue;

// State of a task slot,
// contains the current state of the task () 
// and metadata needed to execute the task (y value of first row).
#define STATE_EMPTY (0)

#define STATE_START (1)
#define STATE_UNPROCESSED (2)
#define STATE_STOP (3)

#define STATE_PROCESSED (4)

typedef struct {
	short startRow;
	unsigned char numRows;

	unsigned char state;
} SlotState;

// A collection of slot states for each slot in a tile queue.
typedef struct {
	SlotState slots[QUEUE_LENGTH];
} TileQueueState;

// A global state of all slots in the entire task queue,
// this is split into seperate tile queue states for each tile.
typedef struct {
	TileQueueState tiles[TILE_NUM];
} QueueState;

#endif 
